/**
 * <p>Title: SoundEffects.java</p>
 * <p>Description: CS 343 Final Project. This class will allow the game to have sound effects</p>
 * @author Tim Olmstead, Brady Fetting, Erik Brown, Thales Kirk
 * @email timothy.olmstead@my.uwrf.edu, brady.fetting@my.uwrf.edu, 
 * 			erik.brown@my.uwrf.edu, thales.kirk@my.uwrf.edu
 * @date November 15, 2013
 */

package Components;

import java.io.File;
import java.io.IOException;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class SoundEffects {

	private String dir = "src/Music/";

	private static boolean muted = false;

	/**
	 * @description plays the sound for death when you crash
	 */
	public void playDeathSound() {
		if (muted)
			return;
		try {
			AudioInputStream sound = AudioSystem.getAudioInputStream(new File(
					dir + "death.wav"));
			Clip bgSound = (Clip) AudioSystem.getLine(new DataLine.Info(
					Clip.class, sound.getFormat()));
			bgSound.open(sound);
			bgSound.start();
		} catch (IOException a) {
		} catch (LineUnavailableException b) {
		} catch (UnsupportedAudioFileException e) {
		}
	}

	/**
	 * @description plays the sound when you jump
	 */
	public void playSpringSound() {
		if (muted)
			return;
		try {
			AudioInputStream sound = AudioSystem.getAudioInputStream(new File(
					dir + "boing.wav"));
			Clip bgSound = (Clip) AudioSystem.getLine(new DataLine.Info(
					Clip.class, sound.getFormat()));
			bgSound.open(sound);
			bgSound.start();
		} catch (IOException a) {
		} catch (LineUnavailableException b) {
		} catch (UnsupportedAudioFileException e) {
		}
	}

	/**
	 * @description plays the sound for the tick in the mouse over on the main
	 *              menu
	 */
	public void playTickSound() {
		if (muted)
			return;
		try {
			AudioInputStream sound = AudioSystem.getAudioInputStream(new File(
					dir + "tick.wav"));
			Clip bgSound = (Clip) AudioSystem.getLine(new DataLine.Info(
					Clip.class, sound.getFormat()));
			bgSound.open(sound);
			bgSound.start();
		} catch (IOException a) {
		} catch (LineUnavailableException b) {
		} catch (UnsupportedAudioFileException e) {
		}
	}

	/**
	 * @description plays the sound for death when you crash
	 */
	public void playEagleSound() {
		if (muted)
			return;
		try {
			AudioInputStream sound = AudioSystem.getAudioInputStream(new File(
					dir + "eagle.wav"));
			Clip bgSound = (Clip) AudioSystem.getLine(new DataLine.Info(
					Clip.class, sound.getFormat()));
			bgSound.open(sound);
			bgSound.start();
		} catch (IOException a) {
		} catch (LineUnavailableException b) {
		} catch (UnsupportedAudioFileException e) {
		}
	}

	/**
	 * @param none
	 * @description returns if its muted or not
	 */
	public boolean isMuted() {
		return muted;
	}

	/**
	 * @param none
	 * @description sets muted to true
	 */
	public void mute() {
		muted = true;
	}

	/**
	 * @param none
	 * @description sets unmuted to false
	 */
	public void unmute() {
		muted = false;
	}

}